﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using AjaxControlFramework;

using BingMapsSample.Components;

namespace BingMapsSample
{
    [AjaxControlOptions(BuildMode = ScriptBuildMode.Debug)]
    public partial class ucPlaceDescription : BaseAjaxControl
    {
        //------// Properties \\--------------------------------------------\\
        private Place _place = null;
        public Place Place
        {
            get
            {
                if (_place == null)
                {
                    _place = (Place)HttpContext.Current.Items["Place"];
                }

                return _place;
            }
        }
        //------\\ Properties //--------------------------------------------//



        //------// Constructors \\------------------------------------------\\
        public ucPlaceDescription()
            : base("~/ucPlaceDescription.ascx")
        { }
        //------\\ Constructors //------------------------------------------//



        //------// Methods \\-----------------------------------------------\\
        public void RenderPlaceDescription(string placeName)
        {
            HttpContext.Current.Items["Place"] = SearchResultsController.GetSearchResults(base.ParentPage.Keyword).FirstOrDefault(p => p.Name == placeName);
        }
        //------\\ Methods //-----------------------------------------------//
    }
}